const mixin = {
  methods: {
    onToggleModel(model:string){
      this.isViewModel = model == "view"
    },
    cancel() {
      if (this.needRefresh) {
        this.$emit('refresh')
      }
      this.$refs.dialog.toggle()
    },
    create(title: string) {
      this.toggle(title, true)
    },
    toggle(title: string, isNew: boolean = false) {
      this.title = title
      this.isNew = isNew
      this.isViewModel = !isNew
      this.$refs.dialog.toggle()
    },
  },
  computed: {
    needRefresh() {
      throw new Error("Need implement needRefresh")
    },
    view() {
      throw new Error("Need implement view")
    }
  },
  data() {
    return {
      isViewModel: true,
      isNew: false,
      title: ''
    }
  }
}
export default mixin